package coint.btc.dao.auth.impl;

import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import coint.btc.base.dao.BaseDAO;
import coint.btc.dao.auth.JuesePermissionCustom;

@Repository
@SuppressWarnings("all")
public class JuesePermissionJpaImpl extends BaseDAO implements JuesePermissionCustom  {

	@Override
	@Transactional(isolation = Isolation.REPEATABLE_READ, propagation = Propagation.REQUIRED,rollbackFor = Exception.class)
	public int deleteJueseQuanXianByJueseID(Integer jueseid) {
		String sql = "delete from juese_permission where juese_id = "+ jueseid;
		int flag = getSession().createSQLQuery(sql).executeUpdate();
		return flag;
	}

	@Override
	@Transactional(readOnly = true, rollbackFor = Exception.class)
	public void distributinQuanxian(Integer jueseid, Integer[] quanxids) {
		StringBuilder sb = new StringBuilder();
        sb.append("insert into juese_permission(juese_id,quanxian_id) values ");
        for(Integer temp:quanxids){
            sb.append("("+jueseid+","+temp+"),");
            
        }
        getSession().createSQLQuery(sb.substring(0, sb.length()-1)).executeUpdate();
		
	}
	
	
	
	
	

}
